package org.wal.userdemo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wal.userdemo.DTO.req.UserDTOReq;
import org.wal.userdemo.entity.UserEntity;
import org.wal.userdemo.mapper.UserMapper;
import org.wal.userdemo.service.UserService;

import java.util.Collections;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 获取用户信息
     *
     * @param id
     * @return UserEntity
     */
    @Override
    public UserEntity getUserById(Integer id) {
        return userMapper.getUserById(id);
    }
    /**
     * 获取所有用户信息
     *
     * @return List<UserEntity>
     */
    @Override
    public List<UserEntity> getAllUsers(UserDTOReq userDTOReq) {
        return userMapper.getAllUsers(userDTOReq) ;
    }
    /**
     * 获取用户数量
     *
     * @return Integer
     */
    @Override
    public Integer getUserCount() {
        return userMapper.getUserCount();
    }
    /**
     * 分页获取用户信息
     *
     * @param pageNum
     * @param pageSize
     * @return List<UserEntity>
     */
    @Override
    public List<UserEntity> getUsersByPage(Integer pageNum, Integer pageSize) {
        return userMapper.getUsersByPage(pageNum, pageSize);
    }
    /**
     * 根据用户名获取用户信息
     *
     * @param name
     * @return List<UserEntity>
     */
    @Override
    public List<UserEntity> getUsersByName(String name) {
        return userMapper.getUsersByName( name);
    }
    /**
     * 添加用户
     *
     * @param userEntity
     * @return Integer
     */
    @Override
    public Integer addUser(UserEntity userEntity) {
        return userMapper.addUser(userEntity);
    }
    /**
     * 修改用户信息
     *
     * @param userEntity
     * @return Integer
     */
    @Override
    public Integer updateUser(UserEntity userEntity) {
        return userMapper.updateUser(userEntity);
    }
    /**
     * 删除用户
     *
     * @param id
     * @return Integer
     */
    @Override
    public Integer deleteUser(Integer id) {
        return userMapper.deleteUser( id);
    }
}
